<?php
namespace App\Admin\Renderable;

use App\Models\User\User;
use Dcat\Admin\Grid;
use Dcat\Admin\Grid\LazyRenderable;

class UserTable extends LazyRenderable
{

    public function grid(): Grid
    {
        $model = User::where('usertype', 1);
        return Grid::make($model, function (Grid $grid) {
            $grid->column('realname', '姓名');
            $grid->column('mobile', '手机号');
            $grid->column('email', '邮箱');
            $grid->column('position', '职位');
            $grid->column('updated_at');

            $grid->quickSearch(['realname', 'mobile', 'email']);

            $grid->paginate(20);
            $grid->disableActions();

            $grid->filter(function (Grid\Filter $filter) {
                $filter->like('realname', '姓名')->width(4);
                $filter->like('mobile', '手机号')->width(4);
                $filter->like('email', '邮箱')->width(4);
            });
        });
    }
}
